<div class="panel panel-default search-panel">
    <div class="panel-body">
        <div class="pull-left">
            <form class="form-inline">
                <div class="form-group">
                    <label class="sr-only" for="query_name">Name</label>
                    <input type="text" ng-model="query_name" id="query_name" class="form-control" placeholder="Name" />
                </div>
                <div class="form-group">
                    <label class="sr-only" for="query_remark">描述</label>
                    <input type="text" ng-model="query_remark" id="query_remark" class="form-control" placeholder="描述" />
                </div>
                <button type="submit" class="btn btn-default" ng-click="query()">查找</button>
            </form>
        </div>
        <div class="pull-right">
            <button type="button" class="btn btn-primary" ng-click="edit()">
                创建数据字典
                <span class="glyphicon glyphicon-plus-sign"></span>
            </button>
        </div>
        <div class="clearfix"></div>
    </div>
</div>

<table class="table table-striped table-bordered table-hover">
    <tr>
        <th>Name</th>
        <th>类型</th>
        <th>Value</th>
        <th>描述</th>
        <th>操作</th>
    </tr>
    <tr ng-repeat="dict in paged.list">
        <td>{{ dict.name }}</td>
        <td>{{ dict.type }}</td>
        <td>{{ dict.value }}</td>
        <td>{{ dict.remark }}</td>
        <td>
            <button type="button" class="btn btn-primary" ng-click="edit(dict)">编辑</button>
            <button type="button" class="btn btn-danger" ng-click="confirmRemove(dict.id)" ng-if="dict.level != LEVEL_SYSTEM">删除</button>
        </td>
    </tr>
</table>

<div ng-include="'app/common/view/paged.html'"></div>

<!-- edit dialog -->
<div class="modal fade" id="editDialog" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">{{ editDialogTitle }}</h4>
            </div>
            <div class="modal-body">
                <div id="editErrorMsg" class="alert alert-danger hide"></div>
                <form class="form-horizontal" role="form">
                    <div class="form-group hidden">
                        <label for="save_id" class="col-sm-2 control-label">id</label>
                        <div class="col-sm-9">
                            <input type="hidden" class="form-control" id="save_id" ng-model="save_id" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="save_name">Name</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="save_name" ng-model="save_name" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="save_type">Type</label>
                        <div class="col-sm-9">
                            <select id="save_type" class="form-control" ng-model="save_type">
                                <option ng-repeat="type in TYPES" value="{{ type }}" ng-selected="type == save_type">{{ type}}</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" id="save_value_group">
                        <label for="save_value" class="col-sm-2 control-label">Value</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="save_value" ng-model="save_value" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="save_remark">描述</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="save_remark" ng-model="save_remark" />
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" ng-click="save()">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<!-- delete dialog -->
<div class="modal fade" id="removeDialog" tabindex="-1">
    <input type="hidden" id="removeId" ng-model="removeId" />
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">删除确认</h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-warning">您确认要删除吗，删除可能会导致程序异常。</div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" ng-click="remove()">确认删除</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>